package com.zcm.org.springframework.web.context;

import java.util.Locale;

import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.NoSuchMessageException;
import org.springframework.util.Assert;

public class ContextHolder {

	private static final Logger logger = Logger.getLogger(ContextHolder.class);
	
	private static ApplicationContext _applicationContext;
	
	private static String DOCUMENT_ROOT;
	
//	private static SchedulerFactory  schedulerFactory = new StdSchedulerFactory();

/*	public static SchedulerFactory getSchedulerFactory() {
		return schedulerFactory;
	}*/

	public static void registerApplicationContext(
			ApplicationContext applicationContext) {
		Assert.notNull(applicationContext);
		_applicationContext = applicationContext;		
	}

	public static Object getBean(String beanName) {
		Assert.notNull(_applicationContext);
		return _applicationContext.getBean(beanName);
	}

	
	
	public static String getMessage(String code, Object[] args,
			String defaultMessage, Locale locale) {
		Assert.notNull(_applicationContext);
		return _applicationContext.getMessage(code, args, defaultMessage,
				locale);
	}

	public static String getMessage(String code, Object[] args, Locale locale)
			throws NoSuchMessageException {
		Assert.notNull(_applicationContext);
		return _applicationContext.getMessage(code, args, locale);
	}

	public static String getMessage(String code) throws NoSuchMessageException {
		Assert.notNull(_applicationContext);
		return _applicationContext.getMessage(code, null, null);
	}

	public static String getMessage(String code, Object[] args)
			throws NoSuchMessageException {
		Assert.notNull(_applicationContext);
		return _applicationContext.getMessage(code, args, null);
	}
	
	
	
	public static String getDocumentRoot() {
		
			return null;
		
	}
}
